﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeus.Thunder.Core;

namespace SharpTrainer.Linq
{
    class GroupByTest2 : ITestCase
    {
        public void Run()
        {
            string[] votes = { "Bush", "Gore", "Gore", "Bush", "Bush" };
            var query = from vote in votes
                        group vote by vote into g
                        orderby g.Count() descending
                        select new { g.Key, Num = g.Count() };
            
            foreach (var gp in query)
            {
                Console.WriteLine(gp.Key);
                Console.WriteLine(gp.Num);
                Console.WriteLine("------------------------------------");
            }
        }
    }
}
